package oop.data;

import java.sql.SQLException;
import java.util.Date;
import java.util.Map;

import oop.db.dao.MixDAO;


public class History {

	private int id;
	private SimpleUser user;
	private long mixId;
	private Mix mix;
	private Date takenDate;
	private double mark;
	private int time;
	private Map<Long,long[]> choices;

	public History() {
		// default constructor
	}
	
	public History(int id, SimpleUser user, long mixId, Date takenDate, 
			double mark, int time, Map<Long,long[]> choices) {
		super();
		this.id = id;
		this.user = user;
		this.mixId = mixId;
		this.takenDate = takenDate;
		this.mark = mark;
		this.time = time;
		this.choices = choices;
	}

	public SimpleUser getUser() {
		return user;
	}

	public Date getTakenDate() {
		return takenDate;
	}

	public double getMark() {
		return mark;
	}

	public int getTime() {
		return time;
	}

	public int getId() {
		return id;
	}
	
	public Mix getMix() {
		if (mix == null) {
			try {
				mix = MixDAO.fetchById(mixId).get(0);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		return mix;
	}
	
	public Test getTest() {
		return getMix().getTest();
	}
	
	public Map<Long,long[]> getChoices() {
		return choices;
	}
	
}
